<?php
namespace  app\model;
use app\utils\Md5Service;
use \think\facade\Db;
use think\facade\Log;
use think\facade\Request;

class WarehouseAttrModel
{


    public  static  function  list($param) :array{


        $where[]=[
            'partner_id','=',$param['partner_id']
        ];
        $where[]=['status','<',3];
        if (isset($param['name'])) {
            $where[] = ['name', 'like', '%' . $param['name'] . '%'];
        }

        $warehouseType=Db::table('xl_warehouse_attr')
            ->where([$where])->limit(($param['page']-1) * $param['limit'], $param['limit'])
            ->select()->toArray();

        $count=Db::table('xl_warehouse_attr')->where([$where])->count();
        return ['list'=>$warehouseType,'count'=>$count];
    }




    /**
     * 新增所有仓库
     * @return void
     */
    public static function add($data)
    {
        $data['add_time']=getNowDateTime();
        return Db::table('xl_warehouse_attr')->insert($data);

    }

    /**
     * 新增所有仓库
     * @return int
     */
    public static function edit($data,$id)
    {

        return Db::table('xl_warehouse_attr')->where('id','=',$id)->update($data);

    }


    /**
     * 删除仓库
     * @return void
     */
    public static function del($id)
    {
        return Db::table('xl_warehouse_attr')->where('id','=',$id)->update(['status'=>3,'update_time'=>getNowDateTime()]);

    }


    public  static  function  info($id){
        return Db::table('xl_warehouse_attr')->where('id','=',$id)->find();
    }


}
